home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1989 / Jul 89 / W0109-Re There really is -Jul89 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.6 KB  |  39 lines  |  [TEXT/GEOL]

  1. Item    1474188                         22-July-89        22:56
  2.  
  3. From:   ROSENSTEIN1                     Rosenstein, Larry
  4.  
  5. To:     CDA0004                         VAR Shana Enterprises, Don Murphy
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    re There really is a bug…
  10.  
  11. After thinking about this, I agree that there is a compiler bug.  But the bug
  12. is that the compiler allows you to pass the result of a cast as a VAR
  13. parameter.  I think the compiler should report this as an error.
  14.  
  15. A cast should be considered a function call that transforms the value.  For
  16. example, you can cast an INTEGER into a LONGINT, and this involves a
  17. computation.  Now, it is true that for Object Pascal (as currently defined) an
  18. object cast does not change the object reference.  In C++ this is not true; a
  19. cast can even involve creating a new object.
  20.  
  21. In the examples given by Wayne, the cast is unnecessary in both test
  22. procedures.  If you remove the casts, then the compiler does what you would
  23. expect.
  24.  
  25. This reveals another compiler bug.  The compiler allows you to pass a TBar
  26. object to a procedure that expects a VAR TFoo object (where TBar is a subclass
  27. of TFoo).  This should be reported as a compiler error, because it allows you
  28. to assign a TFoo object to a variable declared as a TBar.  Since a VAR
  29. parameter is both an input and an output, the compiler should require that you
  30. pass exactly the same type.
  31.  
  32. Defining a MakeFoo procedure what accepts a VAR parameter is perfectly legal.
  33. You would be able to use this procedure to allocate objects, but you would have
  34. to pass variables declared as TFoo.
  35.  
  36. Larry
  37.  
  38.  
  39.